package com.itheima.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.PageResult;
import com.itheima.entity.Result;
import com.itheima.service.OrderListService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/orderlist")
public class OrderListController {

    @Reference
    private OrderListService orderListService;

    @RequestMapping("/findSetmealToQueryString")
    public Result findSetmealToQueryString() {
        try {
            List<String> setmealNames = orderListService.findSetmealToQueryString();

            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, setmealNames);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }

    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody Map map) {

        PageResult page = orderListService.findPage(map);
        System.out.println(page);
        return page;
    }
}
